/// <reference path="../Scripts/jquery-1.7.1.min.js" />
/// <reference path="../Scripts/knockout-2.1.0.js" />

function LoginViewModel() 
	{
    var self = this;
	// put a property loop here
	self.UserName = ko.observable();
			self.Password = ko.observable();
			self.RememberMe = ko.observable();
			
    
    self.LoginList = ko.observableArray([]);
    self.setApplication = function (
			_UserName, _Password, _RememberMe
	
	) {

			UserName = _UserName;
			Password = _Password;
			RememberMe = _RememberMe;
			
        
    }; //  End of set procedure 

	self.Login = function () {

	    //validation 
	    $(".form-login").validate({ rules: { txtUserName: { required: true }, txtPassword: { required: true } } });
	    if (!$(".form-login").valid()) {
	        //alert("Invalied");
	        return;
	    }
      
        var myData = ko.toJSON(this);
        jQuery.ajax({
            url: "./account/login/",
            type: 'post',
            data: myData,
            contentType: 'application/json',
            success: function (result) {
               
                location.href = "./";
            },
            error: function (jqXHR, textStatus, thrownError) {                              
                $('#error-dis').text(thrownError);
                $('#register-error').css({ 'display': 'block' });
                
            }
        });



    }; //End of add procedure

	
    
	self.ForgotPassword = function () {

	    jQuery.ajax({
	        url: "./account/PasswordResetRequest/",
	        type: 'Get',
	        contentType: 'html',
	        success: function (result) {
	            $('#Main').html(result);
	        }
	    });

	};




}; //End of view model






